class AttackableText extends MonoBehaviour
{
 	private var _displayText:boolean;
 	private var _text;
 	
 	private var _isPopup:boolean;
 	private var _translateX:int = 0;
 	
 	private var customGuiStyle : GUIStyle;
 	
 	function AttackableText(){
 		_displayText = false;
 		_isPopup = false;
 		
 		var myFont:Font = Resources.Load("PineappleDemo");
 		
 		customGuiStyle = new GUIStyle();
 		customGuiStyle.fontSize = 25;
 		customGuiStyle.font = myFont;
 		customGuiStyle.normal.textColor = Color.red;
 		customGuiStyle.alignment = TextAnchor.MiddleCenter;
 	}
 	function setText(text, textWidth:int):void{ 
 		_displayText = true;
 		_text = text; 
 		_translateX = textWidth;
 	}
 	function setText(text, textWidth:int, textColour):void{ 
 		_displayText = true;
 		_text = text; 
 		_translateX = textWidth;
 		customGuiStyle.normal.textColor = textColour;
 	}
 	function setText(text, textWidth:int, fontSize, textColour):void{ 
 		_displayText = true;
 		_text = text; 
 		_translateX = textWidth;
 		customGuiStyle.normal.textColor = textColour;
 		customGuiStyle.fontSize = fontSize;
 	}
 	function setAutoRemoveText(text, textWidth:int, time:int, textColour):void{ 
 		_displayText = true;
 		_text = text; 
 		_translateX = textWidth;
 		customGuiStyle.normal.textColor = textColour;
 		Destroy(this, time);
 	}
 	function setAutoRemoveText(text, textWidth:int, time:int):void{ 
 		_displayText = true;
 		_text = text; 
 		_translateX = textWidth;
 		Destroy(this, time);
 	}

 	function Update()
    {
        transform.LookAt(transform.position + Camera.main.transform.rotation * Vector3.forward,
            Camera.main.transform.rotation * Vector3.up);
    }
    function OnGUI(){
    	if(_displayText)
		{
			//calculate rotation for GUI to face camera
			screenPosition = Camera.main.WorldToScreenPoint(transform.position);
    		screenPosition.y = Screen.height - (screenPosition.y + 1); 
			//Display enemy attributes
    		GUI.Label(Rect(screenPosition.x - _translateX, screenPosition.y-10, 100,50), _text, customGuiStyle);//,fontstyle);
		}
    }
}